{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2.1 集合练习\n",
    "# ● 创建一个集合a存放  三国蜀国人物 刘备 赵云 关羽 张飞 诸葛亮\n",
    "# ● 创建一个集合b存放  五虎上将 关羽 赵云 黄忠 张飞  马超\n",
    "# ● 求a和b的并集\n",
    "# ● 求a和b的交集\n",
    "# ● 求a和b的差集\n",
    "# ● 求a和b的异或集\n",
    "\n",
    "a = {'刘备','赵云','关羽','张飞',\"诸葛亮\"}\n",
    "b = {\"关羽\",\"赵云\",\"黄忠\",\"张飞\",\"马超\"}\n",
    "print(a|b)\n",
    "print(a&b)\n",
    "print(a-b)\n",
    "print(b-a)\n",
    "print(a^b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'name': '华为Mate70', 'price': 8888}\n",
      "{'id': 1001, 'name': 'zhangsan', 'chinese': 95, 'math': 87, 'english': 99}\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'id': 1001, 'name': 'zhangsan', 'chinese': 95, 'math': 87, 'english': 99}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "goods = {\"name\":\"华为Mate70\",\"price\":8888}\n",
    "stus = {\"id\":1001,\"name\":\"zhangsan\",\"chinese\":95,\"math\":87,\"english\":99}\n",
    "print(goods)\n",
    "print(stus)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "登录失败\n"
     ]
    }
   ],
   "source": [
    "# 1\n",
    "userInfo = {'username':\"zhangsan\",\"password\":\"1234\"}\n",
    "# 2\n",
    "u = input(\"请输入用户名:\")\n",
    "p = input(\"请输入密码:\")\n",
    "# 3. \n",
    "if u == userInfo[\"username\"] and p == userInfo[\"password\"]:\n",
    "    print(\"登录成功\")\n",
    "else:\n",
    "    print(\"登录失败\")\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "登录失败\n"
     ]
    }
   ],
   "source": [
    "# 1.\n",
    "userInfos = {'zhangsan':'123456','lisi':\"888888\"}\n",
    "# 2\n",
    "u = input(\"请输入用户名:\")\n",
    "p = input(\"请输入密码:\")\n",
    "# 3. \n",
    "if u in userInfos and p == userInfos[u]:\n",
    "    print(\"登录成功\")\n",
    "else:\n",
    "    print(\"登录失败\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
